from django.urls import re_path

from meiduo_admin.views.permissions import PermissionViewSet, GroupViewSet, AdminViewSet
from meiduo_admin.views.skus import SKUImageViewSet, SKUSimpleView
from meiduo_admin.views.users import *
from meiduo_admin.views.statistical import *

urlpatterns = [
    # 定制管理员登录的路由策略
    re_path(r'^authorizations/$', AdminAuthAPIView.as_view()),
    # 定制日活统计数据的路由规则
    re_path(r'^statistical/day_active/$', UserDayActiveView.as_view()),
    # 定制下单用户统计数据的路由规则
    re_path(r'^statistical/day_orders/$', UserDayOrdersView.as_view()),
    # 定制30天日新增用户统计数据的路由规则
    re_path(r'^statistical/month_increment/$', UserMonthCountView.as_view()),
    # 定制用户信息的获取
    re_path(r'^users/$', UserInfoView.as_view()),
    # 定制图片简单信息的获取
    re_path(r'^skus/simple/$', SKUSimpleView.as_view()),
    # 定制权限类型信息的获取
    re_path(r'^permission/content_types/$', PermissionViewSet.as_view({
        'get': "content_types"
    })),
    # 定制权限简单信息的获取
    re_path(r'^permission/simple/$', GroupViewSet.as_view({
        'get': "simple"
    })),
    # 定制组简单信息的获取
    re_path(r'^permission/groups/simple/$', AdminViewSet.as_view({
        'get': "simple"
    })),
]

# 定制动态路由
from rest_framework.routers import DefaultRouter
# 1 定制路由对象
router = DefaultRouter()
# 2 注册视图集
router.register('skus/images',SKUImageViewSet, basename='images')
router.register('permission/perms',PermissionViewSet, basename='perms')
router.register('permission/groups',GroupViewSet, basename='groups')
router.register('permission/admins',AdminViewSet, basename='admins')
# 3 增加路由策略
urlpatterns += router.urls
